import java.nio.charset.StandardCharsets;
import java.util.Scanner;


/***
 * 对于给定的由大小写字母、数字和空格混合构成的字符串s，统计字符 c 在其中出现的次数。具体来说:
 * ∙若c 为大写或者小写字母，统计其大小写形态出现的次数和；
 * ∙若 c 为数字，统计其出现的次数。
 * 保证字符 c 仅为大小写字母或数字。
 *
 * HELLONowcoder123
 * o
 * 3
 */

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String a = "";
        String b = "";
        if (scanner.hasNextLine()) a = scanner.nextLine().trim();
        if (a == null || "".equals(a)) {
            System.out.println(0);
            return;
        }

        if (scanner.hasNextLine()) b = scanner.nextLine();
        if (b == null || "".equals(b) || b.toCharArray().length != 1) {
            System.out.println(0);
            return;
        }


        char[] chars = a.toCharArray();
        char cb = b.toCharArray()[0];
        int count = 0;
        for (int i = 0; i < chars.length; i++) {
            char ca = chars[i];
            if (cb >= '0' && cb <= '9'){
                if (ca == cb){
                    count++;
                    continue;
                }
            }

            if (ca <= 'Z' && ca >= 'A'){
                if (cb == ca || cb == (ca+32)){
                    count++;
                    continue;
                }
            }

            if (ca <= 'z' && ca >= 'a'){
                if (cb == ca || cb == (ca-32)){
                    count++;
                    continue;
                }
            }
        }

        System.out.println(count);
    }
}
